package com.xhwl.logistics.open;

import com.xhwl.common.pojo.ResultJson;
import com.xhwl.logistics.bo.input.PayFeeInfoBO;
import com.xhwl.logistics.converter.ToPayFeeInfoBO;
import com.xhwl.logistics.dto.CarInDTO;
import com.xhwl.logistics.dto.CarOutDTO;
import com.xhwl.logistics.dto.query.PayFeeInfoDTO;
import com.xhwl.logistics.service.IDateReportService;
import com.xhwl.logistics.service.IPayFeeReportedService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @description: 科拓数据上报接口
 * @author: lu.Aaron
 * @create: 2021-07-06 15:39
 **/
@Deprecated   //科拓的车辆进场，出场，缴费的数据上报回传已由KeTopDataPushController替代
//@RestController
@RequestMapping("deprecated-test")
public class KeyTopDataReportController {
    @Autowired
    private IDateReportService dateReportService;

    @Autowired
    private IPayFeeReportedService payFeeReportedService;

    @Autowired
    private ToPayFeeInfoBO toPayFeeInfoBO;

    @ApiOperation(value = "车辆进场上报",notes = "输入框有required标识的字段为必填项", response = ResultJson.class, httpMethod = "POST")
    @ResponseBody
    @RequestMapping(value = "/PostCarInInfo", method = RequestMethod.POST)
    public ResultJson postCarInInfo(@RequestBody @Validated CarInDTO carInDTO) {
        return  dateReportService.postCarInInfo(carInDTO);
    }

    @ApiOperation(value = "车辆出场上报",notes = "输入框有required标识的字段为必填项", response = ResultJson.class, httpMethod = "POST")
    @ResponseBody
    @RequestMapping(value = "/PostCarOutInfo", method = RequestMethod.POST)
    public ResultJson postCarOutInfo(@RequestBody @Validated CarOutDTO carOutDTO) {
        return  dateReportService.postCarOutInfo(carOutDTO);
    }

    //科拓缴费记录上报回调
    @PostMapping("/PostPayFeeInfo")
    public ResultJson<Void> postPayFeeInfo(@RequestBody PayFeeInfoDTO payFeeInfoDTO) {

        PayFeeInfoBO payFeeInfoBO = toPayFeeInfoBO.toToPayFeeInfoBO(payFeeInfoDTO);

        payFeeReportedService.postPayFeeInfo(payFeeInfoBO);

        return ResultJson.successWithVoid();
    }

}
